﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DomainModel;
using Utils;
using System.ComponentModel.DataAnnotations;
using DataAnnotationsExtensions;

namespace WebUI.Models
{
    public class MessageNewViewModel: BaseViewModel
    {
        public MessageNewViewModel()
            : base()
        { }

        

        [NoHtml]
        [Required]
        [Display(Name = "Message")]
        [StringLength(2000,   MinimumLength=50, ErrorMessage = "The Message field has minimum 50 and maximum 2000 characters")]
        public string Message { get; set; }
        public string ReceiptID { get; set; }
        public Boolean CopyMessage { get; set; }

        public Login Sender { get; set; }
        public IndLogin Receiver { get; set; }

        public MessageNewViewModel(string receiptID)
            : base(new { ReceiptID = receiptID})
        {

        }

        protected override void SetVarsWhichDependOnDynamicParams(dynamic dynParams)
        {
            //this id is userName
            ReceiptID = dynParams.ReceiptID;

            Sender = DataUtils.GetLoginByID(Identity.LoginID);
            Receiver = DataUtils.GetIndLoginByUserName(ReceiptID);
        }

        
    }
}